package com.cmes.system.api.bo;

import com.cmes.core.domain.GenericBO;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.google.common.collect.Maps;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotNull;
import java.util.Map;

/**
 * 部门管理
 *
 * @author Bruce.Gong
 * @since 1.0.0-SNAPSHOT
 */
public interface PermissionBO {

    @EqualsAndHashCode(callSuper = true)
    @Data
    public static class AddBO extends GenericBO {
        @NotNull(message = "上级权限不能为空")
        private Long pid;
        @NotNull(message = "权限类型不能为空")
        private Integer type;
        @NotNull(message = "权限名称不能为空")
        private Integer name;
        private String icon;
        private String path;
        private String component;
        private String perm;
        private Integer sort;
        private Boolean visible;
        private String remark;
        private Map<String, Object> meta = Maps.newHashMapWithExpectedSize(4);

        @JsonAnySetter
        public void setMeta(String key, Object name) {
            meta.put(key, name);
        }

    }

    @EqualsAndHashCode(callSuper = true)
    @Data
    public static class UpdateBO extends GenericBO {
        @NotNull(message = "ID不能为空")
        private Long id;
        @NotNull(message = "上级权限不能为空")
        private Long pid;
        @NotNull(message = "权限类型不能为空")
        private Integer type;
        @NotNull(message = "权限名称不能为空")
        private Integer name;
        private String icon;
        private String path;
        private String component;
        private String perm;
        private Integer sort;
        private Boolean visible;
        private String remark;
        private Map<String, Object> meta = Maps.newHashMapWithExpectedSize(4);

        @JsonAnySetter
        public void setMeta(String key, Object name) {
            meta.put(key, name);
        }
    }

}
